<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>宠物领养系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/login.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
    <div class="message">宠物领养系统</div>
    <div id="darkbannerwrap"></div>
    <input name="account" id="account" placeholder="账号" type="text" lay-verify="required" class="layui-input">
    <hr class="hr15">
    <input name="password" id="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
    <hr class="hr15">
    <input type="text" name="username" id="username" lay-verify="required" placeholder="真实姓名" class="layui-input">
    <hr class="hr15">
    <input value="注册" id="btn" class="layui-btn" style="width: 340px;height: 50px;font-size: 28px;">
</div>


<script>

    layui.use(['upload', 'form','element', 'layer'], function(){
        var $ = layui.jquery
            ,upload = layui.upload
            ,element = layui.element
            ,layer = layui.layer;
        var form = layui.form;

        $("#btn").on("click", function () {
            let realname=$("#username").val();
            let password=$("#password").val();
            let account=$("#account").val();
            let role=2;
            if (!account ||!password ||!realname) {
                layer.msg('请输入账号密码和真实姓名，不能为空', {
                    icon: 5,
                    time: 2000
                });
                return;
            }
            $.post('./users/register', {realname,password,account,role}, function(res) {
                if (res.code ===200) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 2000
                    }, function() {
                        window.location.href = "login.html";
                    });
                } else {
                    layer.msg(res.msg, {
                        icon: 5,
                        time: 2000
                    });
                }
            }, "json");
        })
    });

</script>
<!-- 底部结束 -->
</body>
</html>
